# coding:utf-8
from sqlalchemy import Column, Integer, String
from gdb import Base



# 账号表
class DBAccount(Base):
	__tablename__ = 'account'

	account = Column(String(32), primary_key=True)
	password = Column(String(32))
	create_time = Column(Integer(20))
	last_login_time = Column(Integer(20))
	state = Column(Integer(1))
	
	def __init__(self, account, password, create_time, last_login_time, state):
		self.account = account
		self.password = password
		self.create_time = create_time
		self.last_login_time = last_login_time
		self.state = state
	
	def __repr__(self):
		return "<DBAccount(%s)>" % (self.account,)



# 角色表
class DBRole(Base):
	__tablename__ = 'role'

	id = Column(String(32), primary_key=True) 
	account = Column(String(32))
	name = Column(String(10))
	race = Column(Integer(2))
	create_time = Column(Integer(20))

	def __init__(self, id, account, name, race, create_time):
		self.id = id
		self.account = account
		self.name = name
		self.race = race
		self.create_time = create_time
	
	def __repr__(self):
		return "<DBRole(%s,%s,%s)>" % (self.id, self.name, self.account)


# 道具表
class DBItem(Base):
	__tablename__ = 'item'

	id = Column(String(32), primary_key=True) 
	data = Column(String())

	def __init__(self, id, data):
		self.id = id
		self.data = data
	
	def __repr__(self):
		return "<DBItem(%s,%s)>" % (self.id, self.data)

"""
# 事件表
class DBEvent(Base):
	__tablename__ = 'event'

	id = Column(String(32), primary_key=True) 
	role_id = Column(String(32))
	type = Column(Integer(10))
	start_time = Column(Integer(20))

	def __init__(self, id, role_id, type, start_time):
		self.id = id
		self.role_id = role_id
		self.type = type
		self.start_time = start_time
	
	def __repr__(self):
		return "<DBEvent(%s,%d,%d)>" % (self.role_id, self.type, self.start_time)
"""

"""
# 卡牌表
class DBCard(Base):
	__tablename__ = 'card'

	id = Column(String(32), primary_key=True) 
	owner = Column(String(32))
	type = Column(Integer(10))

	exp = Column(Integer(10))
	level = Column(Integer(4))
	quality = Column(Integer(4))

	energy = Column(Integer(10))
	add_atk = Column(Integer(10))
	add_def = Column(Integer(10))
	add_hp = Column(Integer(10))
	add_spd = Column(Integer(10))
	


	def __init__(self, id, owner, type, 
					exp, level, quality, 
					energy, add_atk, add_def, add_hp, add_spd):
		self.id = id
		self.owner = owner
		self.type = type

		self.exp = exp
		self.level = level
		self.quality = quality

		self.energy = energy
		self.add_atk = add_atk
		self.add_def = add_def
		self.add_hp = add_hp
		self.add_spd = add_spd

	
	def __repr__(self):
		return "<DBCard(%s,%d,%d,%d)>" % (self.id, self.type, self.level, self.quality)
"""
"""
# 阵法表
class DBBattleArray(Base):
	__tablename__ = 'battle_array'

	id = Column(String(32), primary_key=True) 
	data = Column(String())

	def __init__(self, id, data):
		self.id = id
		self.data = data
	
	def __repr__(self):
		return "<DBBattleArray(%s,%s)>" % (self.id, self.data)
"""

# 关卡表
class DBMission(Base):
	__tablename__ = 'mission'

	id = Column(String(32), primary_key=True) 
	data = Column(String())

	def __init__(self, id, data):
		self.id = id
		self.data = data
	
	def __repr__(self):
		return "<DBMission(%s,%s)>" % (self.id, self.data)


# 坦克表
class DBCar(Base):
	__tablename__ = 'car'

	id = Column(String(32), primary_key=True) 
	data = Column(String())

	def __init__(self, id, data):
		self.id = id
		self.data = data
	
	def __repr__(self):
		return "<DBCar(%s,%s)>" % (self.id, self.data)

